#include<opencv2/opencv.hpp>
#include <iostream>

using namespace std;
using namespace cv;

float motion_model(float t, Mat beta ){
	return beta.at<float>(2,0)*pow(t, 2)+beta.at<float>(1,0)*t+beta.at<float>(0,0);
}

int main(){
	float t[10]={1, 2, 3, 4,5,6,7,8,9,10};
	Mat beta= Mat::zeros(3, 1, CV_32FC1); 
	beta.at<float>(0,0)=1;
	beta.at<float>(1,0)=2;
	beta.at<float>(2,0)=3;
	//构建A矩阵 
	int N =10;
	Mat A = Mat::zeros(N, 3, CV_32FC1); 
	for (int row = 0;row < A.rows;row++){
		for (int col = 0; col < A.cols;col++){ 
			A.at<float>(row, col) = pow(t[row], col);
		}
	}
	//构建B矩阵
	Mat B = Mat::zeros(N, 1, CV_32FC1);
	for (int row = 0;row < B.rows;row++){ 
		B.at<float>(row,0)= motion_model(t[row],beta);
	}
	cout<<"A "<<A<<endl;
	cout<<"b "<<B<<endl;
	Mat X;
	solve(A, B, X,CV_SVD);
	cout<<"x "<<X<<endl;

	vector<float> his_time;
	his_time.push_back(100.0);
	cout<<"vector test "<<his_time.back()<<endl;


	

	return 0;
}

